// pagesProperty/pages/oa/examine/index.js
var app = getApp(), fetchApi = require("../../../../utils/httpPost.js"), 
common_Js = require("../../../../component/common.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLoading:true,
    pageIndex:1,
    pageSize:10,
    approveList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.onHttpInit();
  },

  /**
   * 获取页面数据的 http请求
   */
  onHttpInit: function () {
    var that = this;
    fetchApi.httpPost('/examine/approve/list', {
      pageSize: that.data.pageSize,
      pageIndex: that.data.pageIndex
    }, function (res) {
      that.data.isNewReq = 0;
      if (res.data.code == 0) {
        if (res.data.totalcount > 0) {
          that.data.pageIndex += 1;
          console.log("审批类目列表", res)
          var approves = res.data.data.approves;
          if(approves.length > 0){
            for (var index in approves) {
              that.data.approveList.splice(that.data.approveList.length, 0, approves[index]);
            }
            that.setData({
              hasData: true,
              approveList: that.data.approveList
            })
          }
        }
      }
      that.setData({
         isLoading: false, loading: true, netWork: true,
      })
    }, function (res) {
        that.setData({ hasData: false,  isLoading: false,  loading: true, netWork: true })
    })
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  goAddRecord(e){
    console.log('goAddRecord',e)
    var item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: './reg/index?aid=' + item.id+'&type=' + item.approveType,
    })
  }
})